﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Hr.Entity;
namespace Chenxin.Lib.Hr.BLL
{
    /// <summary>
    /// 业务逻辑类WorkReport_InBox 的摘要说明。
    /// </summary>
    public class WorkReport_InBox
    {
        public WorkReport_InBox()
        { }
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(Guid RecordId)
        {
            return Chenxin.Lib.Hr.DAL.WorkReport_InBox.Exists(RecordId);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static void Add(Chenxin.Lib.Hr.Entity.WorkReport_InBox model)
        {
            Chenxin.Lib.Hr.DAL.WorkReport_InBox.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static void Update(Chenxin.Lib.Hr.Entity.WorkReport_InBox model)
        {
            Chenxin.Lib.Hr.DAL.WorkReport_InBox.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void Delete(Guid RecordId)
        {

            Chenxin.Lib.Hr.DAL.WorkReport_InBox.Delete(RecordId);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static void DeleteByReportId(Guid ReportId)
        {

            Chenxin.Lib.Hr.DAL.WorkReport_InBox.DeleteByReportId(ReportId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Chenxin.Lib.Hr.Entity.WorkReport_InBox GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Hr.DAL.WorkReport_InBox.GetModel(RecordId);
        }

        public static List<Chenxin.Lib.Hr.Entity.WorkReport_InBox> GetListByReportId(Guid ReportId)
        {
            string strWhere = string.Format("WorkReportId='{0}'", ReportId);
            return GetModelList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Hr.DAL.WorkReport_InBox.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Hr.Entity.WorkReport_InBox> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Hr.DAL.WorkReport_InBox.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List<Chenxin.Lib.Hr.Entity.WorkReport_InBox> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Hr.Entity.WorkReport_InBox> modelList = new List<Chenxin.Lib.Hr.Entity.WorkReport_InBox>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Hr.Entity.WorkReport_InBox model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Hr.Entity.WorkReport_InBox();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["WorkReportId"].ToString() != "")
                    {
                        model.WorkReportId = new Guid(dt.Rows[n]["WorkReportId"].ToString());
                    }
                    if (dt.Rows[n]["ReceiverId"].ToString() != "")
                    {
                        model.ReceiverId = new Guid(dt.Rows[n]["ReceiverId"].ToString());
                    }
                    model.ReceiverName = dt.Rows[n]["ReceiverName"].ToString();
                    if (dt.Rows[n]["ReceiverDepartId"].ToString() != "")
                    {
                        model.ReceiverDepartId = new Guid(dt.Rows[n]["ReceiverDepartId"].ToString());
                    }
                    model.ReceiverDepartName = dt.Rows[n]["ReceiverDepartName"].ToString();
                    if (dt.Rows[n]["ReceiverCompanyId"].ToString() != "")
                    {
                        model.ReceiverCompanyId = new Guid(dt.Rows[n]["ReceiverCompanyId"].ToString());
                    }
                    model.ReceiverCompanyName = dt.Rows[n]["ReceiverCompanyName"].ToString();
                    if (dt.Rows[n]["ReceiverCityId"].ToString() != "")
                    {
                        model.ReceiverCityId = new Guid(dt.Rows[n]["ReceiverCityId"].ToString());
                    }
                    model.ReceiverCityName = dt.Rows[n]["ReceiverCityName"].ToString();
                    if (dt.Rows[n]["isReaded"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isReaded"].ToString() == "1") || (dt.Rows[n]["isReaded"].ToString().ToLower() == "true"))
                        {
                            model.isReaded = true;
                        }
                        else
                        {
                            model.isReaded = false;
                        }
                    }
                    if (dt.Rows[n]["isDeleted"].ToString() != "")
                    {
                        if ((dt.Rows[n]["isDeleted"].ToString() == "1") || (dt.Rows[n]["isDeleted"].ToString().ToLower() == "true"))
                        {
                            model.isDeleted = true;
                        }
                        else
                        {
                            model.isDeleted = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  成员方法
    }
}

